import request from '@/utils/request'

import type {
    getCaptainTaskParams,
    toAuthParams,
    getCaptainAgreementParams
} from '@/types'

/**
 * 获取船长任务信息 */
export const getCaptainTask = (data: getCaptainTaskParams) => {
    return request({ // 发起HTTP请求
        url: '/app/shippingWaybillShip/getCaptainWaybillShipInfoPage', // 请求的API地址
        data, // 请求携带的数据
        method: 'post' // 请求方法为POST
    })
}

// 查找个人信息
export const getInfo = () => {
    return request({
        url: '/app/captain/getCaptain',
        method: 'get'
    })
}

// 已关联企业列表
export const Entlist = (data:any) => {
    return request({
        url: '/app/captain/getRelateEnt',
        method: 'get',
        data
    })
}

// 去认证
export const toAuth = (data: toAuthParams) => {
    return request({
        url: '/app/captain/userUpdateCaptain',
        data,
        method: 'post'
    })
}

// 查询企业是否被关联
export const haslinkEnt = (relateEntCode: string | number) => {
    return request({
        url: '/app/captain/verifyCaptainHasRelateEnt',
        method: 'post',
        data: {
            relateEntCode
        }
    })
}

// 关联企业
export const linkEnt = (relateEntCode:string | number) => {
    return request({
        url: '/app/captain/userCaptainCode',
        data: {
            relateEntCode
        },
        method: 'post'
    })
}

// 修改委托人证件信息
export const updateAssignorInfo = (data:any) => {
    return request({
        url: '/app/assignor/updateUserInfo',
        method: 'post',
        data
    })
}

// 船长协议
export const getAgreement = (data:getCaptainAgreementParams) => {
    return request({
        url: '/app/contract/getUserContractPage',
        method: 'post',
        data
    })
}

// 获取企业
export const getEnt = (data:any) => {
    return request({
        url: '/app/captain/getRelateEnt',
        method: 'get',
        data
    })
}